/**
 * 
 */
package at.fhj.itm10.ticketmaster.services.impl;

import java.util.List;

import org.apache.log4j.Logger;

import at.fhj.itm10.ticketmaster.helper.MailSending;
import at.fhj.itm10.ticketmaster.helper.MailSendingHelper;
import at.fhj.itm10.ticketmaster.services.MailService;

/**
 * {@inheritDoc}
 * 
 * @author Marvin Puchmüller
 */
public class MailServiceImpl extends AbstractService implements MailService {

	private Logger logger = Logger.getLogger(MailServiceImpl.class);
	
	private String subject = "";
	private String content = "";
	private boolean success = false;
	private String eventdate, eventname, username, usergender, userlastname = "";
	private long eventid = 0;
	private MailSending helper = null;

	public MailServiceImpl() {
		helper = new MailSendingHelper();
	}
	
	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		System.out.println("IGetter:"+ content);
		return content;
	}

	public void setContent(String content) {
		System.out.println("ISetter:"+ content);
		this.content = content;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public void sendMailToAll(List<String> mailrecievers) throws Exception {
		helper.setContent(getContent());
		helper.setSubject(getSubject());
		helper.sendMailToAll(mailrecievers);
		setSuccess(helper.isSuccess());
	}

	public String initContent(){
		helper.setUsergender(getUsergender());
		helper.setUserLastname(getUserlastname());
		helper.setEventdate(getEventdate());
		helper.setEventId(getEventid());
		helper.setEventname(getEventname());
		return helper.initContent();
	}
	
	public String initSubjectForUser(){
		helper.setUsername(getUsername());
		return helper.initSubjectForUser();
	}
	
	public String initContentforUser() {
		helper.setContent(helper.initContent());
		helper.setUsergender(getUsergender());
		helper.setUserLastname(getUserlastname());
		helper.setEventdate(getEventdate());
		helper.setEventId(getEventid());
		helper.setEventname(getEventname());
		return helper.initContentforUser();
	}

	public String getEventdate() {
		return eventdate;
	}

	public void setEventdate(String eventdate) {
		this.eventdate = eventdate;
	}

	public String getEventname() {
		return eventname;
	}

	public void setEventname(String eventname) {
		this.eventname = eventname;
	}

	public long getEventid() {
		return eventid;
	}

	public void setEventid(long eventid) {
		this.eventid = eventid;
	}

	public MailSending getHelper() {
		return helper;
	}

	public void setHelper(MailSending helper) {
		this.helper = helper;
	}

	public String getUsergender() {
		return usergender;
	}

	public void setUsergender(String usergender) {
		this.usergender = usergender;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUserlastname() {
		return userlastname;
	}

	public void setUserlastname(String userlastname) {
		this.userlastname = userlastname;
	}
	
}